class SessionsController < ApplicationController
  def new
  end

  def create
    if user = User.authenticate(params[:username], params[:password])
      user.login! session
      user.remember_me cookies if params[:remember_me]
      redirect_to last_uri, :notice => t("notice.logged_in")
    else
      redirect_to login_url, :alert => t("notice.invalid_username_with_password")
    end
  end

  def destroy
    @current_user.forget_me
    session.destroy
    cookies = nil
    redirect_to root_url, :notice => t("notice.logged_out")
  end

end
